package bar.dark.lee.setting.sms.smsinsert;

import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import bar.dark.lee.common.BDUtil;
import bar.dark.lee.setting.sms.InputData;

public class SmsHalbuMoney 
{
	private int smsType; 
//	private boolean flagATM = false;
//	private boolean flagHalbu = false;
	private String halbuMonth = "0";
//	
//	private boolean FLAG = true;
	private boolean available = false;
//	
//	private boolean outmoneyFlag = false;
//	
//	//1:check 2:credit
	private int checkcreditFlag = 0;
//	
	private final int CHECK = 1;
	private final int CREDIT = 2;
//	
	private String message;
	private InputData data;
//	
	private String date;
	
	public SmsHalbuMoney(){};
	
	public SmsHalbuMoney(InputData data, String message, String date, int smsType, int checkcreditFlag)
	{
		this.data = data;
		this.message = message;
		this.date = date;
		this.smsType = smsType;
		this.checkcreditFlag = checkcreditFlag;
		
		halbuMoney();
	}
	
	public boolean getAvailable()
	{
		return available;
	}
	
	public InputData getData()
	{
		return data;
	}
	
	public int getSmsType()
	{
		return smsType;
	}
	
	public String getHalbuMonth()
	{
		return halbuMonth;
	}
	
	private void halbuMoney()
	{
		if ( data.getName().equalsIgnoreCase("KB국민카드") )
		{
			/*
			 KB국민카드
			***님
			06/28 00:01
			70,500원
			G마켓(1566-5701 스타샵
			할부:03개월
			
			KB국민카드
			김난주님
			03/25 21:37
			147,656원(03월)
			네이버체크아웃
			누적 2,427,457원
			 */
			Pattern pName = Pattern.compile("KB국민카드\\s+(.{2,5})님\\s+");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("(\\d{1,2}/\\d{1,2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d원\\(\\d{1,2}월\\)\\s+(.+)\\s+누적");
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMemo2 = Pattern.compile("\\d원\\(\\d{1,2}월\\)\\s+(.+)");
			Matcher mMemo2 = pMemo.matcher(message);
			Pattern pMemo3 = Pattern.compile("\\d원\\s+(.+$)");
			Matcher mMemo3 = pMemo3.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName("KB국민카드" + "(" + mName.group(1) + ")");
				}
			}
			else
			{
				data.setName(data.getName());
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			}
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			else if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1((mMemo2.group(1)));
					data.setMemo2((mMemo2.group(1)));
					data.setMemo3((mMemo2.group(1)));
					data.setMemo4((mMemo2.group(1)));
				}
			}
			else if (mMemo3.find()) 
			{
				for (int i=0; i<mMemo3.groupCount(); i++) 
				{
					data.setMemo1((mMemo3.group(1)));
					data.setMemo2((mMemo3.group(1)));
					data.setMemo3((mMemo3.group(1)));
					data.setMemo4((mMemo3.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if (data.getName().indexOf("KB") != -1)
		{
			/*
			 * KB07/02 18:45 992010**621 ATM입금 30,000 잔액 200,000
			 * 
			 * [KB]08/17 15:43
				910452**381
				김재중
				스마트폰입금
				1,000,000
				
				[KB]09/17 12:38
				623102**030
				이효준
				전자금융입금
				123,123
				잔액456,456
				
				[KB]01/14 18:11
				910755**019
				체크카드할인
				카드입금(   
				2,500
				잔액90,538
				
				[KB]01/23 17:51
				381802**576
				체크카드할인
				카드입금(
				570
			 */
			Pattern pName = Pattern.compile("(\\d{3,}\\*{1,6}\\d{1,})");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("\\s+(\\d*,*\\d*,*\\d*,*\\d)\\s+잔액");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pMoney2 = Pattern.compile("입금\\s+(\\d*,*\\d*,*\\d*,*\\d)");
			Matcher mMoney2 = pMoney2.matcher(message);
			Pattern pMoney3 = Pattern.compile("카드입금\\(\\s+(\\d*,*\\d*,*\\d*,*\\d)");
			Matcher mMoney3 = pMoney3.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
//					Pattern pMemo = Pattern.compile("([^\\s]{2,})\\W*체\\s*크\\s*카\\s*드\\s*출\\s*금\\s*");	// 체크카드 출금 뒤
			Pattern pMemo = Pattern.compile("\\*\\d+\\s+(.+)\\s+\\d*,*\\d*,*\\d*,*\\d\\s+잔액");
			Matcher mMemo = pMemo.matcher(message);
			//Pattern pMemo2 = Pattern.compile("\\*\\d+\\s+[^\\W]+\\s+(.+)\\s+\\d*,*\\d*,*\\d*,*\\d");
			Pattern pMemo2 = Pattern.compile("\\*\\d+\\s+(.+\\s*.+)\\s+\\d*,*\\d*,*\\d*,*\\d");
			Matcher mMemo2 = pMemo2.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName("KB" + "(" + (mName.group(1)) + ")");
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else if (mMoney2.find()) 
			{
				for (int i=0; i<mMoney2.groupCount(); i++) 
				{
					data.setMoney((mMoney2.group(1).replaceAll(",", "")));
				}
			}
			else if (mMoney3.find()) 
			{
				for (int i=0; i<mMoney3.groupCount(); i++) 
				{
					data.setMoney((mMoney3.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1).replaceAll("\\s", " ")));
					data.setMemo2((mMemo.group(1).replaceAll("\\s", " ")));
					data.setMemo3((mMemo.group(1).replaceAll("\\s", " ")));
					data.setMemo4((mMemo.group(1).replaceAll("\\s", " ")));
				}
			}
			else if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1((mMemo2.group(1).replaceAll("\\s", " ")));
					data.setMemo2((mMemo2.group(1).replaceAll("\\s", " ")));
					data.setMemo3((mMemo2.group(1).replaceAll("\\s", " ")));
					data.setMemo4((mMemo2.group(1).replaceAll("\\s", " ")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("삼성카드") != -1) || (data.getName().indexOf("삼성가족카드") != -1)  )
		{
			/*
			 * 삼성카드승인
				09/17 21:33
				171,000원
				3개월
				복지포탈
				*누적
				221,840원
				
				삼성카드승인
				04/06 19:56
				166,000원
				3개월
				멋
				*누적
				1,937,300원
				
				삼성카드승인
				09/28 11:57
				210,000원
				2개월
				하나로축산
				*누적
				502,160원
				
				삼성가족카드승인 04/10 10:34 92,200원 4개월 한국암웨이(주)
			 */
			Pattern pMoney = Pattern.compile("\\s+(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\s+\\d+개월\\s+(.+\\s*.+)\\s+\\*누적");	
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMemo2 = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\s+\\d+개월\\s+(.+$)");	
			Matcher mMemo2 = pMemo2.matcher(message);
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			else if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1((mMemo2.group(1)));
					data.setMemo2((mMemo2.group(1)));
					data.setMemo3((mMemo2.group(1)));
					data.setMemo4((mMemo2.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("삼성증권") != -1) )
		{
			/*
			 * [삼성증권] 12:29
				5990***6투신 CMA
				출금 18,730
				잔액 741,884
				체크카드출금
			 */
			Pattern pName = Pattern.compile(":\\d{1,2}\\s+(.+)\\s+입금");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("입금\\s+(\\d*,*\\d*,*\\d*,*\\d)");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("입금\\s+\\d*,*\\d*,*\\d*,*\\d\\s+(.+$)");	
			Matcher mMemo = pMemo.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("NH카드") != -1) )
		{
			/*
			 * [할부3개월]
				68,420원
				NH카드(2*4*)
				김나연님
				09/17 01:10
				누계 993,597원
				인터파크
			 */
			Pattern pName = Pattern.compile("NH카드(\\(.{4}\\))");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원\\s+NH카드");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("누적금액\\s+\\d*,*\\d*,*\\d*,*\\d원\\s+(.+)\\s*");
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMemo3 = Pattern.compile("누계\\s+\\d*,*\\d*,*\\d*,*\\d원\\s+(.+)\\s*");
			Matcher mMemo3 = pMemo3.matcher(message);
			Pattern pMemo2 = Pattern.compile("\\d{1,2}:\\d{1,2}\\s+(.+$)");
			Matcher mMemo2 = pMemo2.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			if (mMemo3.find()) 
			{
				for (int i=0; i<mMemo3.groupCount(); i++) 
				{
					data.setMemo1((mMemo3.group(1)));
					data.setMemo2((mMemo3.group(1)));
					data.setMemo3((mMemo3.group(1)));
					data.setMemo4((mMemo3.group(1)));
				}
			}
			else if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1((mMemo2.group(1)));
					data.setMemo2((mMemo2.group(1)));
					data.setMemo3((mMemo2.group(1)));
					data.setMemo4((mMemo2.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("기업BC") != -1) || (data.getName().indexOf("경남BC") != -1) || (data.getName().indexOf("대구BC") != -1)
				|| (data.getName().indexOf("씨티BC") != -1) || (data.getName().indexOf("스탠다드차타드BC") != -1)	 
				|| (data.getName().indexOf("우체국BC") != -1) || (data.getName().indexOf("신한BC") != -1))
		{
			/*
			 * [3개월.승인]
				90,000원
				기업BC(5*9*)***님
				05/29 19:10
				가야동물병원
			 */
			
			Pattern pName = Pattern.compile("BC(\\(.{4}\\))");
			Matcher mName = pName.matcher(message);
			Pattern pName2 = Pattern.compile("고객님");
			Matcher mName2 = pName2.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("(\\d{1,2}/\\d{1,2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pDate2 = Pattern.compile("출금안내(\\d{1,2})/(\\d{1,2})결제금액");
			Matcher mDate2 = pDate2.matcher(message);
			Pattern pDate3 = Pattern.compile("님(\\d{1,2})월(\\d{1,2})일\\s+");
			Matcher mDate3 = pDate3.matcher(message);
			Pattern pMemo = Pattern.compile("\\d{2}:\\d{2}\\s+통장잔액-*\\d*,*\\d*,*\\d*,*\\d원\\s*(.+$)");
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMemo2 = Pattern.compile("누적금액\\d*,*\\d*,*\\d*,*\\d원\\.(.+$)");
			Matcher mMemo2 = pMemo2.matcher(message);
			Pattern pMemo3 = Pattern.compile("님\\s+\\d{1,2}/\\d{1,2}\\s+\\d{2}:\\d{2}\\s+(.+$)");
			Matcher mMemo3 = pMemo3.matcher(message);
			Pattern pMemo4 = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\.[\\d*TOP적립예정\\.*]*(.+$)");
			Matcher mMemo4 = pMemo4.matcher(message);
			Pattern pMemo5 = Pattern.compile("(후불교통요금\\s+출금안내\\d{1,2}/\\d{1,2})결제금액");
			Matcher mMemo5 = pMemo5.matcher(message);
			Pattern pMemo6 = Pattern.compile("\\d{2}:\\d{2}\\s+(.+$)");
			Matcher mMemo6 = pMemo6.matcher(message);
			Pattern pMemo7 = Pattern.compile("님\\d{1,2}월\\d{1,2}일\\s+(.+$)");
			Matcher mMemo7 = pMemo7.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else if (mName2.find())
			{
				data.setName(data.getName().substring(0, data.getName().indexOf("BC")+2) + "후불교통요금");
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				if (mDate2.find())
				{
					data.setDate(date.substring(0, 4) + mDate2.group(1) + mDate2.group(2));
				}
				else if (mDate3.find())
				{
					data.setDate(date.substring(0, 4) + mDate3.group(1) + mDate3.group(2));
				}
				else 
				{
					data.setDate(date);
				}	
			} 
			else if (mDate2.find())
			{
				data.setDate(calendar.get(Calendar.YEAR) + mDate2.group(1) + mDate2.group(2));
			}
			else if (mDate3.find())
			{
				data.setDate(calendar.get(Calendar.YEAR) + mDate3.group(1) + mDate3.group(2));
			}
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1(mMemo.group(1));
					data.setMemo2(mMemo.group(1));
					data.setMemo3(mMemo.group(1));
					data.setMemo4(mMemo.group(1));
				}
			}
			else if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1(mMemo2.group(1));
					data.setMemo2(mMemo2.group(1));
					data.setMemo3(mMemo2.group(1));
					data.setMemo4(mMemo2.group(1));
				}
			}
			else if (mMemo3.find()) 
			{
				for (int i=0; i<mMemo3.groupCount(); i++) 
				{
					data.setMemo1(mMemo3.group(1));
					data.setMemo2(mMemo3.group(1));
					data.setMemo3(mMemo3.group(1));
					data.setMemo4(mMemo3.group(1));
				}
			}
			else if (mMemo4.find()) 
			{
				for (int i=0; i<mMemo4.groupCount(); i++) 
				{
					data.setMemo1(mMemo4.group(1));
					data.setMemo2(mMemo4.group(1));
					data.setMemo3(mMemo4.group(1));
					data.setMemo4(mMemo4.group(1));
				}
			}
			else if (mMemo5.find()) 
			{
				for (int i=0; i<mMemo5.groupCount(); i++) 
				{
					data.setMemo1(mMemo5.group(1));
					data.setMemo2(mMemo5.group(1));
					data.setMemo3(mMemo5.group(1));
					data.setMemo4(mMemo5.group(1));
				}
			}
			else if (mMemo6.find()) 
			{
				for (int i=0; i<mMemo6.groupCount(); i++) 
				{
					data.setMemo1(mMemo6.group(1));
					data.setMemo2(mMemo6.group(1));
					data.setMemo3(mMemo6.group(1));
					data.setMemo4(mMemo6.group(1));
				}
			}
			else if (mMemo7.find()) 
			{
				for (int i=0; i<mMemo7.groupCount(); i++) 
				{
					data.setMemo1(mMemo7.group(1));
					data.setMemo2(mMemo7.group(1));
					data.setMemo3(mMemo7.group(1));
					data.setMemo4(mMemo7.group(1));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("신한카드") != -1) )
		{
			/*
			 * 
			 * 신한카드정상승인***님        08/19 16:33     134,010원( 2개월) ㈜이마트 가양
			 */
			
			Pattern pName = Pattern.compile("신한카드\\s+(.{2,6}님)");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("(\\d{2}/\\d{2})");
			Matcher mDate = pDate.matcher(message);
			//Pattern pMemo = Pattern.compile("\\d원\\s+(.+)\\s+잔액");	// ???원 뒤에
			Pattern pMemo = Pattern.compile("\\d원\\s*\\n*\\s*\\n*(.+$)");	// ???원 뒤에
			Matcher mMemo = pMemo.matcher(message);
			//Pattern pMemo4 = Pattern.compile("\\d원\\s+(.+)\\s+누적");	// ???원 뒤에
			
			if (data.getName().indexOf("신한카드") != -1)
			{
				if (mName.find())
				{
					for (int i=0; i<mName.groupCount(); i++) 
					{
						data.setName(data.getName() + "(" + (mName.group(1)) + ")");
					}
				}
				else
				{
					available = false;
					return;
				}
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
				available = true;
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if (data.getName().indexOf("현대카드") != -1)
		{
			/*
			 * [현대카드M3]-승인
				최순*님
				178,000원(06개월)
				G마켓(1566-5701
				누적:xxx,xx0원
			 */
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\s*(.+$)");
			Matcher mMemo = pMemo.matcher(message);
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1((mMemo.group(1)));
					data.setMemo2((mMemo.group(1)));
					data.setMemo3((mMemo.group(1)));
					data.setMemo4((mMemo.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("농협BC") != -1) )
		{
			/*
			 * 				
				농협BC(3*3*)정현진님.11/01 00:45.10개월.128,000원.1,024TOP적립예정.(주)씨제이오쇼핑
				농협BC(1*2*)양선희님.01/04 12:38.일시불.10,000원.누적금액590,090원.메가박스씨너
			 */
			
			Pattern pName = Pattern.compile("(\\(\\d\\*\\d\\*\\))");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo2 = Pattern.compile("누적금액\\d*,*\\d*,*\\d*,*\\d원\\.(.+$)");
			Matcher mMemo2 = pMemo2.matcher(message);
			Pattern pMemo3 = Pattern.compile("님\\s+\\d{1,2}/\\d{1,2}\\s+\\d{2}:\\d{2}\\s+(.+$)");
			Matcher mMemo3 = pMemo3.matcher(message);
			Pattern pMemo4 = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\..+적립예정\\.(.+$)");
			Matcher mMemo4 = pMemo4.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
				//originalParsing();
			}
			
			if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1(mMemo2.group(1));
					data.setMemo2(mMemo2.group(1));
					data.setMemo3(mMemo2.group(1));
					data.setMemo4(mMemo2.group(1));
				}
			}
			else if (mMemo4.find()) 
			{
				for (int i=0; i<mMemo4.groupCount(); i++) 
				{
					data.setMemo1(mMemo4.group(1));
					data.setMemo2(mMemo4.group(1));
					data.setMemo3(mMemo4.group(1));
					data.setMemo4(mMemo4.group(1));
				}
			}
			else if (mMemo3.find()) 
			{
				for (int i=0; i<mMemo3.groupCount(); i++) 
				{
					data.setMemo1(mMemo3.group(1));
					data.setMemo2(mMemo3.group(1));
					data.setMemo3(mMemo3.group(1));
					data.setMemo4(mMemo3.group(1));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( data.getName().equalsIgnoreCase("우리카드") || data.getName().equalsIgnoreCase("부산BC") ) 
		{
			/*
			 * 우리카드(9*1*)권하정님.11/06 16:42.3개월86,700원.누적금액190,929원.쿠팡
			 */
			
			
			Pattern pName = Pattern.compile("(\\(\\d\\*\\d\\*\\))");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d*,*\\d*,*\\d*,*\\d원\\.[\\d*TOP적립예정\\.*]*(.+$)");	
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMemo2 = Pattern.compile("지급가능액\\s*\\d*,*\\d*,*\\d*,*\\d원\\s+(.+$)");	
			Matcher mMemo2 = pMemo2.matcher(message);
			Pattern pMemo5 = Pattern.compile("출금가능액\\s*\\d*,*\\d*,*\\d*,*\\d원\\s+(.+$)");	
			Matcher mMemo5 = pMemo5.matcher(message);
			Pattern pMemo3 = Pattern.compile("님\\s+\\d{1,2}/\\d{1,2}\\s+\\d{1,2}:\\d{1,2}\\s+(.+$)");	
			Matcher mMemo3 = pMemo3.matcher(message);
			Pattern pMemo4 = Pattern.compile("누적금액\\s*\\d*,*\\d*,*\\d*,*\\d원\\.(.+$)");	
			Matcher mMemo4 = pMemo4.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
			}
			
			if (mMemo2.find()) 
			{
				for (int i=0; i<mMemo2.groupCount(); i++) 
				{
					data.setMemo1(mMemo2.group(1));
					data.setMemo2(mMemo2.group(1));
					data.setMemo3(mMemo2.group(1));
					data.setMemo4(mMemo2.group(1));
				}
			}
			else if (mMemo5.find()) 
			{
				for (int i=0; i<mMemo5.groupCount(); i++) 
				{
					data.setMemo1(mMemo5.group(1));
					data.setMemo2(mMemo5.group(1));
					data.setMemo3(mMemo5.group(1));
					data.setMemo4(mMemo5.group(1));
				}
			}
			else if (mMemo4.find()) 
			{
				for (int i=0; i<mMemo4.groupCount(); i++) 
				{
					data.setMemo1(mMemo4.group(1));
					data.setMemo2(mMemo4.group(1));
					data.setMemo3(mMemo4.group(1));
					data.setMemo4(mMemo4.group(1));
				}
			}
			else if (mMemo3.find()) 
			{
				for (int i=0; i<mMemo3.groupCount(); i++) 
				{
					data.setMemo1(mMemo3.group(1));
					data.setMemo2(mMemo3.group(1));
					data.setMemo3(mMemo3.group(1));
					data.setMemo4(mMemo3.group(1));
				}
			}
			else if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1(mMemo.group(1));
					data.setMemo2(mMemo.group(1));
					data.setMemo3(mMemo.group(1));
					data.setMemo4(mMemo.group(1));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( (data.getName().indexOf("롯데카드") != -1) )
		{
			/*
			 * 롯데카드 ***님 4*7*카드 558,330원 할부(06) 06/05 10:21 악사손해보험(주)(AXA G
			 */
			Pattern pName = Pattern.compile("(\\d\\*\\d\\*)");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d{2,}:\\d{2,}\\s+(.+$)");	
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMonth = Pattern.compile("할부\\((\\d{1,2})\\)");	
			Matcher mMonth = pMonth.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + "(" + (mName.group(1)) + ")");
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
			}
			
			if (mMonth.find())
			{
				halbuMonth = mMonth.group(1);
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1(mMemo.group(1));
					data.setMemo2(mMemo.group(1));
					data.setMemo3(mMemo.group(1));
					data.setMemo4(mMemo.group(1));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		else if ( data.getName().equalsIgnoreCase("롯데") )
		{
			/*
			 * 롯데 임수*(2*4*) 88,000원 할부(03) 02/09 15:43 롯데홈쇼핑[무이자] 누적348,400원
			 */
			Pattern pName = Pattern.compile("(\\(\\d\\*\\d\\*\\))");
			Matcher mName = pName.matcher(message);
			Pattern pMoney = Pattern.compile("(\\d*,*\\d*,*\\d*,*\\d)원");
			Matcher mMoney = pMoney.matcher(message);
			Pattern pDate = Pattern.compile("([\\d]{2}[/][\\d]{2})");
			Matcher mDate = pDate.matcher(message);
			Pattern pMemo = Pattern.compile("\\d{2,}:\\d{2,}\\s+(.+)\\s+");	
			Matcher mMemo = pMemo.matcher(message);
			Pattern pMonth = Pattern.compile("할부\\((\\d{1,2})\\)");	
			Matcher mMonth = pMonth.matcher(message);
			
			if (mName.find())
			{
				for (int i=0; i<mName.groupCount(); i++) 
				{
					data.setName(data.getName() + (mName.group(1)));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMoney.find()) 
			{
				for (int i=0; i<mMoney.groupCount(); i++) 
				{
					data.setMoney((mMoney.group(1).replaceAll(",", "")));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			Calendar calendar = Calendar.getInstance();
			if (date != null && date.length() > 0)
			{
				data.setDate(date);
			} 
			else if (mDate.find()) 
			{
				for (int i=0; i<mDate.groupCount(); i++) 
				{
					data.setDate(calendar.get(Calendar.YEAR)+(mDate.group(1).replaceAll("/", "")));
				}
			}
			else
			{
				data.setDate(BDUtil.getDateDB(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)));
			}
			
			if (mMonth.find())
			{
				halbuMonth = mMonth.group(1);
			}
			else
			{
				available = false;
				return;
			}
			
			if (mMemo.find()) 
			{
				for (int i=0; i<mMemo.groupCount(); i++) 
				{
					data.setMemo1(mMemo.group(1));
					data.setMemo2(mMemo.group(1));
					data.setMemo3(mMemo.group(1));
					data.setMemo4(mMemo.group(1));
				}
			}
			else
			{
				available = false;
				return;
			}
			
			available = true;
		}
		
		
		
		if (data.getName() == null || data.getName().equalsIgnoreCase(""))
		{
			available = false;
			return;
		}
		if (data.getDate() == null || data.getDate().equalsIgnoreCase(""))
		{
			available = false;
			return;
		}
		if (data.getMoney() == null || data.getMoney().equalsIgnoreCase(""))
		{
			available = false;
			return;
		}
		if ( (data.getMemo1() == null) || (data.getMemo1().equalsIgnoreCase("")) 
				&& ( (data.getMemo2() == null) || (data.getMemo2().equalsIgnoreCase("")) )
				&& ( (data.getMemo3() == null) || (data.getMemo3().equalsIgnoreCase("")) )
				&& ( (data.getMemo4() == null) || (data.getMemo4().equalsIgnoreCase("")) ) )
		{
			available = false;
			return;
		}
	}
}
